package com.demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-12-21
 * Time: 20:28
 */

class Singleton{
    private static Singleton instance = new Singleton();
    //构造函数
    private Singleton(){}
    //类外拿到
    public static Singleton getInstance(){
        //已经实例化 无需判断
        return instance;
    }
}


//单例模式-饿汉模式
public class TestDemo {
    public static void main(String[] args) {

    }
}
